﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Video;
using IAlarm;

namespace TestAlarm
{
    public partial class Form1 : Form
    {

        UserVideo video = null;
        public Form1()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            video = new UserVideo();
            video.BorderStyle = BorderStyle.FixedSingle;
            video.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            video.Alarm += new EventHandler<IVideo.AlarmEventArgs>(video_Alarm);
            video.Bounds = new Rectangle(12, 12, 160, 100);
            video.Initialize("计算机学院", "楼顶大镜头1");
            this.Controls.Add(video);
            video.LoginEncoder();
            video.OpenVideo();
        }

        void video_Alarm(object sender, IVideo.AlarmEventArgs e)
        {
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            if (video != null)
            {
                if (video.IsOpened) video.CloseVideo();
                if (video.IsLogined) video.LogoutEncoder();
            }

            base.OnClosing(e);
        }

        private void cBAnalyze_CheckedChanged(object sender, EventArgs e)
        {
        }

        private void cBOpenClose_CheckedChanged(object sender, EventArgs e)
        {
            if (cBOpenClose.Checked) video.OpenVideo();
            else  video.CloseVideo();
        }

        private void bOpen_Click(object sender, EventArgs e)
        {
            video.StartTrainingAngle();
        }

    }
}
